# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=nextcloud-client
pkgver=3.4.4
pkgrel=1
pkgdesc="Nextcloud Desktop Client"
url="https://github.com/nextcloud/desktop"
# s390x, ppc64le and riscv64 blocked by qt5-qtwebengine
# armhf blocked by extra-cmake-modules
arch="all !s390x !ppc64le !armhf !riscv64"
license="GPL-2.0-only"
depends="dbus:org.freedesktop.Secrets"
makedepends="
	$depends_dev
	cmake
	doxygen
	extra-cmake-modules
	graphviz
	inkscape
	kio-dev
	qt5-qtkeychain-dev
	qt5-qtquickcontrols2-dev
	qt5-qttools-dev
	qt5-qtwebengine-dev
	qt5-qtwebsockets-dev
	samurai
	"
checkdepends="xvfb-run"
subpackages="$pkgname-dev $pkgname-dolphin"
source="$pkgname-$pkgver.tar.gz::https://github.com/nextcloud/desktop/archive/refs/tags/v$pkgver.tar.gz
	Nextcloud.conf"
builddir="$srcdir/desktop-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_SYSCONFDIR=/etc/$pkgname \
		-DMIRALL_VERSION_SUFFIX=""
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dm644 "$srcdir"/Nextcloud.conf "$pkgdir"/etc/Nextcloud/Nextcloud.conf
}

dolphin() {
	pkgdesc="$pkgdesc - KDE Dolphin integration"
	install_if="$pkgname dolphin"

	mkdir -p "$subpkgdir"/usr/lib "$subpkgdir"/usr/share

	amove usr/lib/qt5
	amove usr/lib/libnextclouddolphinpluginhelper.so
	amove usr/share/kservices5
}

sha512sums="
880d615147feed915595bf6e4f99c3c7588d03b910bdee934429ccdbc16c2a0e7b07be99665729d60cb68c22a140cfd21c0cc821fd1c4499bc6ea4aec515eaf4  nextcloud-client-3.4.4.tar.gz
28faf643e3ba22f3e1f45a96acfba1b3c53c49d4e923974e58e5ad2fdda612f52300608f0e0219e61d3478403fe3c59a9a2c70c3db1c93fbccda1e0638ecbc22  Nextcloud.conf
"
